<template>
  <div class="">
    <h3>正在进行:{{ goingArr.length }}</h3>
    <ul>
      <li v-for="(item,index) in goingArr" :key="item.id">
        <input type="checkbox" @click="go(index)" />
        <div class="text">
          <span v-show="!item.ifinput" @click="item.ifinput = true">{{
            item.content
          }}</span>
          <input
            type="text"
            v-show="item.ifinput"
            v-model="item.content"
            v-focus="item.ifinput"
            @blur="item.ifinput = !item.ifinput"
          />
        </div>
        <div class="x" @click="gogg(index)">X</div>
      </li>
    </ul>
  </div>
</template>
 
<script>
import { mapState, mapMutations } from "vuex";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapState({
      goingArr: (state) => state.todolist.goingArr,
    }),
  },
  methods: {
    ...mapMutations({
      // ccc:'todolist/ccc'
      go: "todolist/go",
      gogg: "todolist/gogg",
    }),
  },
  directives: {
    focus: {
      update(el, binding) {
        if (binding.value) {
          el.focus();
        }
      },
    },
  },
};
</script>
 
<style lang = "less" scoped>
h3 {
  margin-top: 10px;
}
li {
  height: 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: #fff;
  margin-top: 10px;
  box-sizing: border-box;
  font-size: 18px;
}
li .text{
  flex: 1;
}
li input {
  margin-right: 10px;
}
li .x {
  width: 30px;
  height: 30px;
  font-size: 12px;
  border: 1px solid #000;
  text-align: center;
  line-height: 30px;
  cursor: pointer;
}
li div span {
  margin-right: 5px;
}
li div input {
  text-indent: 1em;
  outline: none;
}
</style>